<script lang="ts" setup>

import{ref} from "vue"
import { User } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
import { GetUser } from "@/utils/lStorage"

// import { apiUserLogout } from '@/api/apiUser'


const router = useRouter()

const userInfo =  ref(GetUser())
const handleLogout = () => {

  localStorage.removeItem('user');
  handleJumpToLogin()
}

const handleJumpToUserInfo = () => {
  router.push({ path: '/user/detail', query: { "id": userInfo.value.id } })

}

const handleJumpToLogin = () => {
  router.push({ path: '/login' })
}


</script>

<style scoped>
.example-showcase .el-dropdown+.el-dropdown {
  margin-left: 15px;
}

.example-showcase .el-dropdown-link {
  cursor: pointer;
  color: var(--el-color-primary);
  display: flex;
  align-items: center;
}
</style>

<template>
  <div class="flex flex-wrap items-center">
    <el-dropdown>
      <el-button size="large" circle>
        <el-icon>
          <User />
        </el-icon>
      </el-button>
      <template #dropdown>
        <el-dropdown-menu>
          <el-dropdown-item @click="handleJumpToUserInfo">详情</el-dropdown-item>
          <el-dropdown-item @click="handleLogout">登出</el-dropdown-item>
        </el-dropdown-menu>
      </template>
    </el-dropdown>
  </div>
</template>

